package cn.wolfcode.luowowo.article.service.impl;

import cn.wolfcode.luowowo.article.domain.Getgogo;
import cn.wolfcode.luowowo.article.mapper.GetgogoMapper;
import cn.wolfcode.luowowo.article.service.IGetgogoService;
import cn.wolfcode.luowowo.cache.service.IRedisService;
import cn.wolfcode.luowowo.cache.util.RedisKeysUtil;
import cn.wolfcode.luowowo.common.exception.LogicException;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import javax.xml.crypto.Data;
import java.util.Date;
import java.util.List;

@Service
public class GetgogoSerivceImpl implements IGetgogoService {

    @Autowired
    private GetgogoMapper getgogoMapper;

    @Reference
    private IRedisService redisService;

    @Override
    public int deleteByPrimaryKey(Long id) {
        return 0;
    }

    @Override
    public int insert(Getgogo record) {
        String key = RedisKeysUtil.VERIFY_CODE.join(record.getPhone());
        String code = redisService.getVerifyCode(key);
        if(code == null){
            throw new LogicException("该验证码已失效");
        }
        Date date = new Date();
        return getgogoMapper.insert(record);
    }

    @Override
    public Getgogo selectByPrimaryKey(Long id) {
        return null;
    }

    @Override
    public List<Getgogo> selectAll() {
        return null;
    }

    @Override
    public int updateByPrimaryKey(Getgogo record) {
        return 0;
    }
}
